<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/199F9/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ice="http://www.icesoft.com/icefaces/component"  
	template="layout/template.xhtml">

	<ui:define name="body">
		 	<h:messages id="messages" globalOnly="true" styleClass="message" errorClass="errormsg" infoClass="infomsg" warnClass="warnmsg"/>
		
		<ice:form id="selectionPanelForm" styleClass="edit">
		  <ice:panelGroup>
              <f:facet name="header">
                <ice:panelGroup>
                    <ice:outputText id="linkHeader"
                            value="LeaderBoard Selection Utility Panel"/>
                </ice:panelGroup>
              </f:facet>
          <ice:panelGroup styleClass="formBorderHighlight" rendered="#{leaderBoard.visible}">
			 <ui:decorate template="layout/hint.xhtml">
			 	<ui:param name="id" value="leaderBoardTip"/>
			 	<ui:param name="headerText" value="Using the leaderboard"/>
			 	<p>To make the leaderboard work, first open two separate browsers (you need to have separate sessions). Then, create a leaderboard view for a course in the first window. Once that is loaded, use the other window to login and enter a new round for that course. Return to this leaderboard view and you'll see that round appear in the list.</p>
			 </ui:decorate>
			<h3>Select course information to show leaderboard</h3>
			<s:decorate id="courseField" template="layout/display.xhtml">
					<ui:define name="label">Course And TeeSet</ui:define>
					<ice:selectOneListbox size="10" value="#{leaderBoard.teeSet}" partialSubmit="true">
					    <s:selectItems var="_ts" value="#{teeSets}" label="#{_ts.course.name} - #{_ts.nameOrColor}" />
					     <s:convertEntity />
					</ice:selectOneListbox>
			</s:decorate>
		 </ice:panelGroup>
		 <ice:panelGroup rendered="#{not leaderBoard.renderPush}">	
			<div class="actionButtons">
				<s:button id="createLBListId" value="Create Leaderboard View" 
				           view="/leaderBoard.xhtml" 
				           action="#{leaderBoard.create}">
				       <f:param name="teeSetId" value="#{leaderBoard.teeSetId}"/>
				</s:button>
			</div>
  
		  </ice:panelGroup>
		  <ice:panelGroup rendered="#{leaderBoard.renderPush}">
			 <ice:outputText value="This view is now setup for Ajax Push"/>
		  </ice:panelGroup>
		</ice:panelGroup>		
		</ice:form>
		
		<ice:panelGroup styleClass="formBorderHighlight" rendered="#{not leaderBoard.teeSetIdEmpty}" >
		
		  <div class="results" id="LeaderBoardResults">
	
			<h:outputText value="No rounds found." rendered="#{empty leaderBoardManager.roundsLookup[leaderBoard.teeSet.id]}}"/>
	
		    <ice:form>
		      <h3>Top 10 LeaderBoard for course and tee set: #{leaderBoard.teeSet.course.name} - #{leaderBoard.teeSet.nameOrColor}</h3>
		    <i>  <h4>Men's Course Rating: #{not empty leaderBoard.teeSet.mensCourseRating ? leaderBoard.teeSet.mensCourseRating : 'n/a'}</h4>
		      <h4>Ladies' Course Rating: #{not empty leaderBoard.teeSet.ladiesCourseRating ? leaderBoard.teeSet.ladiesCourseRating : 'n/a'}</h4></i>  
		      <ice:outputText value="There are currently no rounds entered for that TeeSet" 
		                     rendered="#{empty leaderBoardManager.roundsLookup[leaderBoard.teeSet.id]}"/> 
		      <ice:panelGroup styleClass="formBorderHighlight" rendered="#{not empty leaderBoardManager.roundsLookup[leaderBoard.teeSet.id]}">
  		   
			     <ice:dataTable id="leaderListId" var="_round" value="#{leaderBoardManager.roundsLookup[leaderBoard.teeSet.id]}" 
				      resizable="true" columnClasses="allCols">
					<ice:column id="totalScoreColumn">
						<f:facet name="header">
							<ice:outputText value="Score"/>
						</f:facet>
						<ice:outputText value="#{_round.totalScore}"/>
					</ice:column>
					<ice:column id="firstNameColumn">
						<f:facet name="header">
							<ice:outputText value="First Name"/>
						</f:facet>
						<ice:outputText value="#{_round.golfer.firstName}"/>
					</ice:column>
					<ice:column id="lastNameColumn">
						<f:facet name="header">
							<ice:outputText value="Last Name"/>
						</f:facet>
						<ice:outputText value="#{_round.golfer.lastName}"/>
					</ice:column>																		      
					<ice:column id="dateColumn">
						<f:facet name="header">
							<ice:outputText id="dateTextColumnId" value="Date"/>
						</f:facet>
						<ice:outputText value="#{_round.date}">
							<s:convertDateTime type="date" />
						</ice:outputText>
					</ice:column>
					<ice:column id="courseColumn">
						<f:facet name="header">
							<ice:outputText value="Course Name"/>
						</f:facet>
						<ice:outputText value="#{_round.teeSet.course.name}"/>
					</ice:column>
					<ice:column id="teeSetColumn">
						<f:facet name="header">
							<ice:outputText value="Tee Colour"/>
						</f:facet>
						<ice:panelGroup>
						  <div title="#{_round.teeSet.color}" class="teeMarker" 
						    style="background-color: #{_round.teeSet.color};" />
						</ice:panelGroup>
					</ice:column>
					<ice:column id="weatherColumn">
						<f:facet name="header">
							<ice:outputText value="Weather"/>
						</f:facet>
						<ice:outputText value="#{_round.weather}"/>
					</ice:column>
					<ice:column id="genderColumn">
						<f:facet name="header">
							<ice:outputText value="Gender"/>
						</f:facet>
						<ice:outputText value="#{_round.golfer.gender}"/>
					</ice:column>
				</ice:dataTable>

		   </ice:panelGroup>	
	    </ice:form>
	  </div>
	  <s:button view="/home.xhtml"  action="#{leaderBoard.destroy}" propagation="end" value="Discard View"/>
	 </ice:panelGroup>
	<br/>
	</ui:define>

</ui:composition>

	
